@echo off
chcp 65001 >nul

echo 检查是否已有 RocketMQ 进程运行...
tasklist | findstr /i "java.exe" | findstr /i "mqnamesrv mqbroker" >nul
if %errorlevel% equ 0 (
    echo 检测到 RocketMQ 进程正在运行，请先关闭对应窗口后重试！
    pause
    exit /b 1
)

echo [1/2] 启动 RocketMQ NameServer...
cd /d %ROCKETMQ_HOME%\bin
start "NameServer 日志" mqnamesrv.cmd

echo 等待 5 秒，确保 NameServer 完成初始化...
ping -n 6 127.0.0.1 >nul

echo [2/2] 启动 RocketMQ Broker...
start "Broker 日志" mqbroker.cmd -n localhost:9876 autoCreateTopicEnable=true

echo 启动完成
pause
